<style type="text/css">
    .bjui-pageHeader{
        font-size: 18px;
        font-weight: bold;
    }
    .form{
        padding: 15px;
    }
    .form dl {
        overflow: hidden;
        padding-top: 15px;
    }

    .form dt {
        color: #666;
        float: left;
        font-size: 14px;
        padding: 3px 0 0;
        width: 11%;
    }
    .form dd {
        float: left;
        line-height: 22px;
    }
    dd.desc {
        height: 30px;
        padding: 0 10px;
        width: 150px;
    }
</style>
<script type="text/javascript">
    $(function(){
        var uid =<if condition="$user['id'] gt 0">{$user.id}<else/>0</if>;
        var validate={username:1,code:1};
        $("input[name='username']").focus();//聚焦
        //验证用户名
        $("input[name='username']").blur(function(){
            var username = $("input[name='username']");
            if($.trim(username.val())==''){
                validate.username=1;
                username.parent().find("span").remove().end().append("<span class='error'>用户名不能为空</span>");
                return ;
            }
            $.post("{:U('Auth/checkusername')}",{username:$.trim(username.val()), id:uid},function(stat){
                if(stat==1){    
                    validate.username=1;            
                    username.parent().find("span").remove().end().append("<span class='error'>用户已经存在</span>");
                }else{                  
                    validate.username=0;    
                    username.parent().find("span").remove();
                }
        
            })          
        });

        $("#form_do").submit(function(){
            if(validate.username==0){
                return true;
            }
            //验证用户名
            $("input[name='username']").trigger("blur");
            return false;
        });
    });
</script>
<div class="bjui-pageHeader">
    <div class="glyphicon glyphicon-th-large">
        <if condition='$uid'>
            修改管理
            <else/>
            添加管理
        </if>
    </div>
</div>
<div class="bjui-pageContent">
    <div class="form">
        <form method='post' id="form_do" name="form_do" action="<if condition='$uid'>
            {:U('Auth/editUser')}
            <else/>
            {:U('Auth/addUserHandle')}
        </if>
        "  data-toggle="validate">
        <dl>
            <dt>用户名：</dt>
            <dd>
                <input type="text" name="username" value="{$user.username}"  class="input-nm" size="30"  data-rule="required" data-tip="请填写用户名" data-ok="OK"/>
            </dd>
        </dl>
        <dl>
            <dt>密码：</dt>
            <dd>
                <input type="password" name="password" value="{$user.password}" class="input-nm" size="30"/>
            </dd>
        </dl>

        <dl>
            <dt>所属权限组：</dt>
            <dd>
                <select name="group_id"  data-toggle="selectpicker" data-width="200">
                    <foreach name='role' item='v'>
                        <option value="{$v.id}" <if condition="$v['id'] eq $userRote['group_id']">selected="selected"</if>
                        >{$v.title}
                    </option>
                </foreach>
            </select>
        </dd>
    </dl>
    <dl>
        <dt>锁定：</dt>
        <dd>
            <input type="radio" name="islock" value="1" <if condition='$user.status eq 1'>checked="checked"</if>
        />是
                &nbsp;&nbsp;
        <input type="radio" name="islock" value="0" <if condition='$user.status eq 0'>checked="checked"</if>
    />否
</dd>
</dl>
<if condition="$uid">
    <input type="hidden" name="uid" value="{$uid}" />
</if>
</form>
</div>
</div>
<div class="bjui-pageFooter">
<ul>
<li>
<button type="button" class="btn-close" data-icon="close">关闭</button>
</li>
<li>
<button data-icon="save" class="btn btn-default" type="submit">保存</button>
</li>
</ul>
</div>